package com.zisuyi.uilibrary.module.activty.login

import com.umeng.analytics.MobclickAgent
import com.weilele.mvvm.base.helper.createStatusLiveData
import com.zisuyi.game.sdk.GameApp
import com.zisuyi.game.sdk.library.login.IGameLogin
import com.zisuyi.game.sdk.net.GameModel
import com.zisuyi.game.sdk.net.bean.UserInfoBean
import com.zisuyi.game.sdk.utils.UserData

import com.zisuyi.uilibrary.base.BaseUiViewModel

class UserLoginViewModel : BaseUiViewModel() {

    val userInfoData = createStatusLiveData<UserInfoBean>()

    fun userLogin(userInfo: IGameLogin.UserInfo) {
        userInfoData.retrofitGame(isToastError = false) {
            val bean = GameModel.userLogin(userInfo)
            UserData.userInfo = bean.data
            UserData.uid = userInfo.id
            GameApp.secret = bean.data?.secret
            //umeng 账号统计
            MobclickAgent.onProfileSignIn(userInfo.type,userInfo.id)
            bean
        }
    }
}